<template>
  <div class="nav-bar" :class="{'is-fixed':isFixed}">
    <div class="container">
      <div class="pro-title">小米8 透明探索版</div>
      <div class="pro-param">
        <a href="javascript:">概述</a><span>|</span>
        <a href="javascript:">参数</a><span>|</span>
        <a href="javascript:">用户评价</a>
        <slot name="buy"></slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "productParam",
  data() {
    return {
      isFixed: false
    }
  },
  mounted() {
    window.addEventListener('scroll', this.initHeight)
  },
  methods: {
    initHeight() {
      //到152时自动吸附到顶部    。。。/谷歌/ie
      let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
      this.isFixed = scrollTop >= 152;
    }
  },
  destroyed() {
    //页面销毁时销毁事件
    window.removeEventListener('scroll', this.initHeight, false)
  }
}
</script>

<style scoped lang="scss">
@import "~@/assets/scss/mixin.scss";
@import "~@/assets/scss/config.scss";

.nav-bar {
  height: 70px;
  line-height: 70px;
  border-top: 1px solid $colorH;
  z-index: 10;

  &.is-fixed {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: $colorG;
    box-shadow: 0 3px 5px $colorE;
  }

  .container {
    @include flex();

    .pro-title {
      font-size: $fontH;
      font-weight: bold;
      color: $colorB;
    }

    .pro-param {
      font-size: $fontJ;


      a {
        color: $colorC;
        margin: 0 10px;
      }

      span {
      }
    }
  }

}
</style>
